from os import path
import sys
import subprocess
import os

print("Generate the bin file")
shell_script =  '''cd {sdk_dir}
make clean
rm -rf {sdk_dir}/build
mkdir -p {sdk_dir}/build/libs
cp -arf {out_dir}/libs/* {sdk_dir}/build/libs/.
make -j16
cp -arf {sdk_dir}/build/STM32F429DISCOVERY.elf {out_dir}'''.format(sdk_dir=sys.argv[1], out_dir=sys.argv[2])
print(shell_script)
ret = os.system(shell_script)
if ret != 0 :
    sys.exit(1)
